<div id="div.auth.baseinfo.script">
 	<table border=0>
 		<tr><td height=40>操作 ： <span id="tip"/> </td></tr>
 		<tr>
 			<td height=40>脚本编号 ：<input type="text" id="scriptid" name="scriptid" size=50 value=""> 
 			  	<input type="button" id="addScript" name="addScript" value="添加" onclick="scriptinsert();">
 			</td>
 		</tr>
 	</table>
</div>
<div id="div.auth.baseinfo.scriptlist"></div>

<script type="text/javascript">
	var dataURL = '/data/sc.action';
	
	var loadAuthScript = function(){
		try {
			var request = new Request.JSON({
				url: dataURL,
				onComplete: function(json,text) {
					var content = '';
						if(null != json.recorders && json.recorders.length>0){
						   content='<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" >';
						   content += '<tr><td>脚本编号: </td><td></td></tr>';
					 	   json.recorders.each(function(item, index){
    		 			 		content += '<tr><td>'+item.scid+'</td><td><a href="#" onclick="scriptdelete(\''+item.id+'\');">删除</a></td></tr>';
							});
    		 				content += '</table>';
						} 
					$('div.auth.baseinfo.scriptlist').set('html',content);
				}
			}).get({"scid":"authscript_1","authid":nodeinfo.id});
		} catch (ex) {
			MUI.notification('<font color=red>错误：</font>访问失败('+ex.message+')');
		}
	}
	
	var fillcontent = function(){
		//nodeinfo 从auth.tree.html的onNodeClick事件传过来的
	 	if(nodeinfo!=null){
			$('tip').set('html', '您正在添加 [ '  + nodeinfo.title + ' ]节点的对应脚本');
		}else{
			$('tip').set('html', '错误 [未取得节点信息] ');
		}
		loadAuthScript();
	}

	var scriptdelete = function(id){
		try {
			var request = new Request.JSON({
				url: dataURL,
				onComplete: function(json,text) {
					if (json.error.errorcode==0){
		 				MUI.notification('删除成功！');
		 				loadAuthScript();
		 			}else{
		 				MUI.notification('<font color=red>错误：</font>('+json.error.retstring+')');
		 			}
				}
			}).get({"scid":"authscript_2","id":id});
		} catch (ex) {
			MUI.notification('<font color=red>错误：</font>访问失败('+ex.message+')');
		}
	}
	
	var scriptinsert = function(){
		if(null==$('scriptid').get('value') || ""==$('scriptid').get('value').trim()) {
			MUI.notification('<font color=red>错误：</font>(脚本编号必须填写)');
			return;
		} 
		try {
			var request = new Request.JSON({
				url: dataURL,
				onComplete: function(json,text) {
					if (json.error.errorcode==0){
		 				MUI.notification('添加成功！');
		 				$('scriptid').set('value','');
		 				loadAuthScript();
		 			}else{
		 				MUI.notification('<font color=red>错误：</font>('+json.error.retstring+')');
		 			}
				}
			}).get({"scid":"authscript_3","authid":nodeinfo.id, "scriptid": $('scriptid').get('value')});
		} catch (ex) {
			MUI.notification('<font color=red>错误：</font>访问失败('+ex.message+')');
		}
	}
	
	 window.addEvent('domready', function() {
	 	fillcontent();
	 });

</script>